package com.ruoyi.wms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wms.domain.WmsInventoryLog;
import com.ruoyi.wms.service.IWmsInventoryLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

/**
 * 库存操作日志Controller
 * 
 * @author ruoyi
 * @date 2024-07-12
 */
@Api(tags = "库存操作日志管理")
@RestController
@RequestMapping("/wms/inventoryLog")
public class WmsInventoryLogController extends BaseController
{
    @Autowired
    private IWmsInventoryLogService wmsInventoryLogService;

    /**
     * 查询库存操作日志列表
     */
    @ApiOperation("查询库存操作日志列表")
    @PreAuthorize("@ss.hasPermi('wms:inventoryLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsInventoryLog wmsInventoryLog)
    {
        startPage();
        List<WmsInventoryLog> list = wmsInventoryLogService.selectWmsInventoryLogList(wmsInventoryLog);
        return getDataTable(list);
    }

    /**
     * 导出库存操作日志列表
     */
    @ApiOperation("导出库存操作日志列表")
    @PreAuthorize("@ss.hasPermi('wms:inventoryLog:export')")
    @Log(title = "库存操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsInventoryLog wmsInventoryLog)
    {
        List<WmsInventoryLog> list = wmsInventoryLogService.selectWmsInventoryLogList(wmsInventoryLog);
        ExcelUtil<WmsInventoryLog> util = new ExcelUtil<WmsInventoryLog>(WmsInventoryLog.class);
        util.exportExcel(response, list, "库存操作日志数据");
    }

    /**
     * 获取库存操作日志详细信息
     */
    @ApiOperation("获取库存操作日志详细信息")
    @ApiImplicitParam(name = "logId", value = "日志ID", required = true, dataType = "Long", paramType = "path")
    @PreAuthorize("@ss.hasPermi('wms:inventoryLog:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(wmsInventoryLogService.selectWmsInventoryLogById(logId));
    }



    /**
     * 新增库存操作日志
     */
    @ApiOperation("新增库存操作日志")
    @PreAuthorize("@ss.hasPermi('wms:inventoryLog:add')")
    @Log(title = "库存操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsInventoryLog wmsInventoryLog)
    {
        return toAjax(wmsInventoryLogService.insertWmsInventoryLog(wmsInventoryLog));
    }

    /**
     * 修改库存操作日志
     */
    @ApiOperation("修改库存操作日志")
    @PreAuthorize("@ss.hasPermi('wms:inventoryLog:edit')")
    @Log(title = "库存操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsInventoryLog wmsInventoryLog)
    {
        return toAjax(wmsInventoryLogService.updateWmsInventoryLog(wmsInventoryLog));
    }

    /**
     * 删除库存操作日志
     */
    @ApiOperation("删除库存操作日志")
    @ApiImplicitParam(name = "logIds", value = "日志ID数组", required = true, dataType = "Long[]", paramType = "path")
    @PreAuthorize("@ss.hasPermi('wms:inventoryLog:remove')")
    @Log(title = "库存操作日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(wmsInventoryLogService.deleteWmsInventoryLogByIds(logIds));
    }
}